// (c) 2008 Kickstone Technology Ltd

#pragma once

#include <map>
#include <list>
#include "CriticalSection.h"

class CRebarHandler;
class CButtonDemoBHO;

// class to handle representation of each Browser Window
// Used to track tabs in IE7
class CIEWindow {
public:
	CIEWindow(HWND hWnd);
	~CIEWindow();

	// set the current BHO for this window
	void setCurrentBHO(CButtonDemoBHO *bho);

	// manage the IEWindow class for the hWnd
	static CIEWindow *findWindow(HWND hWnd);
	static CIEWindow *addWindow(HWND hWnd);
	static void removeWindow(HWND hWnd);

	// handle the BHOs for this window
	void addBHO();
	void removeBHO();
	CButtonDemoBHO *getCurrentBHO();

	// various settings for the browser
	int getIEVersion(){return m_ieVer;}

private:

	// the current BHO for the window
	CButtonDemoBHO *m_currentBHO;

	// general variables
	HWND m_hWnd;
	CRebarHandler *m_rebarHandler;
	int m_ieVer;
	CCriticalSection m_cs;
	int m_bhoCnt;

	// static list and CS to track all windows in a single IE process
	static CCriticalSection m_globalCS;
	typedef std::map<HWND, CIEWindow*> WindowMap;
	static WindowMap m_Windows;

};
